﻿<DocumentContent x:Class="Poet.Views.DocumentView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 Title="{Binding Title}" Height="259" Width="875"
                 DefaultElement="{Binding TextEditor}"
                 x:Name="this">
         
    <DocumentContent.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources\XamlCollections.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        </ResourceDictionary>
    </DocumentContent.Resources>

    <DocumentContent.InputBindings>
        <KeyBinding Key="Escape" Command="Close"/>
        <KeyBinding Key="X" Modifiers="Alt" Command="Close"/>
    </DocumentContent.InputBindings>

    <DocumentContent.CommandBindings>
        <CommandBinding Command="Close"/>
    </DocumentContent.CommandBindings>

    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Menu
            Name="MainMenu"
            IsMainMenu="False"
            Visibility="{Binding ShowMainMenu, Converter={StaticResource BooleanToVisibilityConverter}}"
            Background="{Binding ElementName=ToolBarTray, Path=Background}">

            <Menu.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="..\Resources\MenuResources.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </Menu.Resources>

            <MenuItem Header="{Localizing File}">
                <MenuItem Header="{Localizing New}" Command="{Binding New}" Icon="{Picture Icons/New_16x16.png, 16}"/>
                <MenuItem Header="{Localizing Open}" Command="{Binding Open}" Icon="{Picture Icons/Open_16x16.png, 16}"/>
                <Separator/>
                <MenuItem Header="{Localizing Save}" Command="ApplicationCommands.Save" Icon="{Picture Icons/Save_16x16.png, 16}"/>
                <MenuItem Header="{Localizing SaveAs}" Command="ApplicationCommands.SaveAs"/>
                <Separator/>
                <MenuItem Header="{Localizing Close}" Command="ApplicationCommands.Close"/>
                <Separator/>
                <MenuItem Header="{Localizing PageSetup}" Command="PreviousPage" Icon="{Picture Icons/PageSetup_16x16.png, 16}"/>
                <MenuItem Header="{Localizing Print}" Command="ApplicationCommands.Print" Icon="{Picture Icons/Print_16x16.png, 16}"/>
                <Separator/>
                <MenuItem Header="{Localizing Recent}"/>
                <MenuItem Header="{Localizing Pinned}"/>
                <Separator/>
                <MenuItem Header="{Localizing Exit}" Command="{Binding Exit}" Icon="{Picture Icons/Exit_16x16.png, 16}"/>
            </MenuItem>

            <MenuItem Header="{Localizing Edit}" ItemsSource="{StaticResource EditMenuItems}"/>

            <MenuItem Header="{Localizing Format}" ItemsSource="{StaticResource FormatMenuItems}"/>

            <MenuItem Header="{Localizing View}">
                <MenuItem Header="{Localizing ToolBars}" ItemsSource="{StaticResource ToolBarTrayMenuItems}"/>
                <MenuItem Header="{Localizing ShowStatusBar}" IsCheckable="True" IsChecked="{Binding ShowStatusBar}"/>
            </MenuItem>

            <MenuItem Header="{Localizing Help}" ItemsSource="{StaticResource HelpMenuItems}"/>

        </Menu>

        <ToolBarTray Grid.Row="1" Name="ToolBarTray">

            <ToolBarTray.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="..\Resources\ToolBarTrayResources.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </ToolBarTray.Resources>

            <ToolBarTray.ContextMenu>
                <ContextMenu ItemsSource="{StaticResource ToolBarTrayMenuItems}" />
            </ToolBarTray.ContextMenu>

            <ToolBar Visibility="{Binding ElementName=this, Path=DataContext.ShowStandartToolBar,  Mode=TwoWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}">

                <Button Command="{Binding Open}" Content="{Picture Icons/Open_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
                <Button Command="ApplicationCommands.Save" Content="{Picture Icons/Save_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
                <Separator/>
                <Button Command="ApplicationCommands.Cut" Content="{Picture Icons/Cut_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
                <Button Command="ApplicationCommands.Copy" Content="{Picture Icons/Copy_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
                <Button Command="ApplicationCommands.Paste" Content="{Picture Icons/Paste_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
                <Button Command="ApplicationCommands.Delete" Content="{Picture Icons/Delete_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
                <Separator/>
                <Button Command="ApplicationCommands.Undo" Content="{Picture Icons/Undo_16x16.png, 16}" ToolTip="{Localizing UndoToolTip}"/>
                <Button Command="ApplicationCommands.Redo" Content="{Picture Icons/Redo_16x16.png, 16}" ToolTip="{Localizing RedoToolTip}"/>

            </ToolBar>

            <ToolBar
                DataContext="{Binding TextEditor}"
                ItemsSource="{StaticResource FormatToolBarItems}"
                Visibility="{Binding ElementName=this, Path=DataContext.ShowFormatToolBar, Mode=TwoWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}"/>

            <ToolBar
                DataContext="{Binding TextEditor}"
                ItemsSource="{StaticResource HighlightingToolBarItems}"
                Visibility="{Binding ElementName=this, Path=DataContext.ShowHighlightToolBar, Mode=TwoWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}"/>

        </ToolBarTray>

        <ContentControl Grid.Row="2" Name="TextEditorContentControl" Content="{Binding TextEditor}">
            <ContentControl.ContextMenu>
                <ContextMenu>

                    <MenuItem Header="{Localizing Undo}" Command="ApplicationCommands.Undo" Icon="{Picture Icons/Undo_16x16.png, 16}"/>
                    <MenuItem Header="{Localizing Redo}" Command="ApplicationCommands.Redo" Icon="{Picture Icons/Redo_16x16.png, 16}"/>
                    <Separator/>
                    <MenuItem Header="{Localizing Cut}" Command="ApplicationCommands.Cut" Icon="{Picture Icons/Cut_16x16.png, 16}"/>
                    <MenuItem Header="{Localizing Copy}" Command="ApplicationCommands.Copy" Icon="{Picture Icons/Copy_16x16.png, 16}"/>
                    <MenuItem Header="{Localizing Paste}" Command="ApplicationCommands.Paste" Icon="{Picture Icons/Paste_16x16.png, 16}"/>
                    <MenuItem Header="{Localizing Delete}" Command="ApplicationCommands.Delete" Icon="{Picture Icons/Delete_16x16.png, 16}"/>
                    <Separator/>
                    <MenuItem Header="{Localizing SelectAll}" Command="ApplicationCommands.SelectAll"/>
                    <Separator/>
                    <MenuItem Header="{Localizing View}">
                        <MenuItem Header="{Localizing ToolBars}" ItemsSource="{StaticResource ToolBarTrayMenuItems}"/>
                        <MenuItem Header="{Localizing ShowStatusBar}" IsCheckable="True" IsChecked="{Binding ShowStatusBar}"/>
                    </MenuItem>
                    <MenuItem Header="More..." ItemsSource="{Binding ElementName=MainMenu, Path=Items}">
                    </MenuItem>

                </ContextMenu>
            </ContentControl.ContextMenu>
        </ContentControl>

        <StatusBar Grid.Row="3" ItemsSource="{StaticResource StatusBarItems}" Visibility="{Binding ShowStatusBar, Converter={StaticResource BooleanToVisibilityConverter}}"/>

    </Grid>
    
</DocumentContent>
